﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;
using PloobsEngine.Input;
using PloobsEngine.Commands;
using PloobsEngine.MessageSystem;
using PloobsEngine;

namespace Etapa1.Objects
{
    public class lightControler
    {

        int id;
        public lightControler(int lightId)
        {
            this.id = lightId;
            SimpleConcreteKeyboardInputPlayable sc = new SimpleConcreteKeyboardInputPlayable(StateKey.DOWN, Keys.J, key, EntityType.TOOLS);
            BindKeyCommand k6 = new BindKeyCommand(sc, BindAction.ADD);
            CommandProcessor.getCommandProcessor().SendCommandSyncronous(k6);

            sc = new SimpleConcreteKeyboardInputPlayable(StateKey.DOWN, Keys.K, key, EntityType.TOOLS);
            k6 = new BindKeyCommand(sc, BindAction.ADD);
            CommandProcessor.getCommandProcessor().SendCommandSyncronous(k6);
        }

        private void key(InputPlayableKeyBoard ipk)
        {
            if (ipk.Keys[0] == Keys.J)
            {
                Message m = new Message(PrincipalConstants.EventSenderId, id, null, Priority.VERYLOW, 0, SenderType.NORMAL, null, "esquerda");
                MessageDeliver.SendMessage(m);
            }
            else if (ipk.Keys[0] == Keys.K)
            {
                Message m = new Message(PrincipalConstants.EventSenderId, id, null, Priority.VERYLOW, 0, SenderType.NORMAL, null, "direita");
                MessageDeliver.SendMessage(m);
            }
        }
    }
}
